Some object not seeing module level attributes

HELP I am totally baffled by this one. I have a script which refreshes attributes for objects according to the setting of module level attributes.

I recently modified script to check if module level attributes exist before using them (as I had added some more but didn't want to have create the new attributes in all the existing modules).

What I now see is that for some objects the module level attributes are detected as not existing even though they do! I have included the basis of the part of the script below. The first print displays the atribute in question correctly even when the "if exists" doesn't think it does!

void populate_RPE_exportAttrsinallmods () {
string attr1 = ""

print "dmp: populate_RPE_exportAttrsinallmods : " fullName(mod) " : " obj."_Tag" " : " mod."_RPE ExportAttr1" "\n"
if (exists attribute "_RPE ExportAttr1") print "dmp: " mod."_RPE ExportAttr1" "\n"

if (exists attribute "_RPE ExportAttr1") {
attr1 = mod."_RPE ExportAttr1"""
print "dmp: pre-call : " attr1 "\n"
updateRPEExportAttribute(attr1, "_RPE ExportAttr1_Object")
}
......

This is the output for a failing object ("No." is what : _RPE ExportAttr1 contains):

dmp: populate_RPE_exportAttrsinallmods : /850007 - DNVG Julius/2. System Level/2.2 System Verification/Acceptance Test Procedure : ATP_/14837/1 : No.

The objects it doesn't work for are at the same level as each other, in fact out of three together the one in the middle might not see the _RPE ExportAttr1 atribute! I have tried deleting and re-creating the module level attribute.

Thanks in advance. (using DOORS 9.2.0.0)
DMP - Fri Jul 13 05:58:11 EDT 2012

Re: Some object not seeing module level attributes
MichaelGeorg - Fri Jul 13 07:05:09 EDT 2012

I'm not sure if this is the cause of you problem, but are you aware that the value of "exists attribute <attr name>" depends on the current module?
Because a DXL-attribute or some method in your script can easily change which module is the current one, I don't use "exists atttribute <attr name>" any more, but use "find(<module>, <attr name>)" instead. So perhaps try something like:

AttrDef testAd = null
testAd = find(m, "my_attr")
 
if(!null testAd) {
    print "found"
}

 


Hoping this is helpful for you
- Michael

 

Re: Some object not seeing module level attributes
DMP - Mon Jul 16 06:46:32 EDT 2012

MichaelGeorg - Fri Jul 13 07:05:09 EDT 2012

I'm not sure if this is the cause of you problem, but are you aware that the value of "exists attribute <attr name>" depends on the current module?
Because a DXL-attribute or some method in your script can easily change which module is the current one, I don't use "exists atttribute <attr name>" any more, but use "find(<module>, <attr name>)" instead. So perhaps try something like:

AttrDef testAd = null
testAd = find(m, "my_attr")
 
if(!null testAd) {
    print "found"
}

 


Hoping this is helpful for you
- Michael

 

Thanks for the response. I will bear your solution in mind for future use. In this case I am parsing all the objects in the current module following links to a constrained set of modules so I know I am in the correct module (as proven by the debug I added).

I have tinkered a bit more:

If I copy an object in question the script fails on the copy object.
If I create a new object and copy all attributes values and set the links as
per the original object the script works.

In conclusion it would appear that I have some sort of corruption in some objects within the module which copy object seems to perpetuate!

Guess I will have to re-create all the object in question.

Is there a way of checking module/objects for corruptions?

Thanks in advance
Darren